﻿@{
    ViewBag.Title = "Open_List";
    string type = Request.QueryString["typeid"];
}
<form action="" method="post">
    @Html.AntiForgeryToken()
    <table cellpadding="0" cellspacing="1" border="0" width="99%" align="center">
        <tr>
            <td align="left" height="35">
                名称：<input type="text" class="mytext" style="width:160px;" id="flow_name" value="" name="flow_name" />
                <input type="button" onclick="query(null, 1); return false;" class="mybutton" value=" 查询 "/>
            </td>
        </tr>
    </table>

    <table id="listtable"></table>
    <div class="buttondiv"></div>
</form>   
<script type="text/javascript">
    var frame = null;
    var curPageSize = '@Request.QueryString["pagesize"]';
    var curPageNumber = '@Request.QueryString["pagenumber"]';
    var appid = '@Request.QueryString["appid"]';
    var typeid = '@Request.QueryString["typeid"]';
    var openerid = '@Request.QueryString["openerid"]';
    $(function ()
    {
        //var dataGrid = new RoadUI.Grid({ table: $(".mygrid"), showpager: false, height:350 });
        var iframes = top.frames;
        for (var i = 0; i < iframes.length; i++)
        {
            var fname = "";
            try
            {
                fname = iframes[i].name;
            }
            catch (e)
            {
                fname = "";
            }
            if (fname == openerid + "_iframe")
            {
                frame = iframes[i]; break;
            }
        }
        if (frame == null) return;

        $("#listtable").jqGrid({
            url: RoadUI.Core.rooturl() + "/WorkFlowDesigner/Query",
            postData: { "__RequestVerificationToken": $("input[name='__RequestVerificationToken']").val(), appid: appid, typeid: typeid, openlist: 1, },
            mtype: 'POST',
            datatype: "json",
            colNames: ['流程名称', '创建时间', '创建人', '状态', ''],
            colModel: [
                { name: 'Name', index: 'Name', width: 260 },
                { name: 'CreateDate', index: 'CreateDate', width: 110 },
                { name: 'CreateUserID', index: 'CreateUserID', width: 80 },
                { name: 'Status', index: 'Status', width: 50 },
                { name: 'Edit', index: '', sortable: false, width: 50 }
            ],
            sortname: "CreateDate",
            sortorder: "desc",
            height: '100%',
            width: $(window).width(),
            loadComplete: function ()
            {
                var gridObj = $("#listtable");
                var records = gridObj.getGridParam("userData");
                curPageSize = records.pagesize;
                curPageNumber = records.pagenumber;
                $(".buttondiv").html(RoadUI.Core.getPager1(records.total, records.pagesize, records.pagenumber, "query"));
            }
        });
    });
    function query(size, number)
    {
        var data = {
            __RequestVerificationToken: $("input[name='__RequestVerificationToken']").val(),
            flow_name: $("#flow_name").val(), appid: appid, typeid: typeid, openlist: 1,
            pagesize: size || curPageSize, pagenumber: number || curPageNumber
        };
        $("#listtable").setGridParam({ postData: data }).trigger("reloadGrid");
    }
    function typechange(type)
    {

    }
    function openflow(id)
    {
        frame.openFlow1(id);
        new RoadUI.Window().close();
    }
</script>
